$(function (){
    layui.use('form', function(){
        let form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(){
            let id=$("input[name='id']").val();
            let username=$("input[name='username']").val();
            let password=$("input[name='password']").val();
            let email=$("input[name='email']").val();
            let address=$("input[name='address']").val();
            let phone=$("input[name='phone']").val();
            let qq=$("input[name='qq']").val();
            let wechat=$("input[name='wechat']").val();
            let registerTime=$("input[name='registerTime']").val();
            console.log(id);
            console.log(username);
            console.log(password);
            console.log(email);
            console.log(address);
            console.log(phone);
            console.log(qq);

            $.ajax({
                type    : 'PUT',
                url     : '/editUser',
                data: {
                    "id": id,
                    "username": username,
                    "password": password,
                    "email": email,
                    "address": address,
                    "phone":phone,
                    "qq": qq,
                    "wechat": wechat,
                    "registerTime":registerTime
                },
                dataType:"text"
            });
            //调用父页面实现窗口自动关闭和后台数据实时刷新
            window.parent.location.reload();
            var index=parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);

        });
    });
})